
user/_ls:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <fmtname>:
#include "kernel/fs.h"
#include "kernel/btree.h"

char*
fmtname(char *path)
{
   0:	7179                	addi	sp,sp,-48
   2:	f406                	sd	ra,40(sp)
   4:	f022                	sd	s0,32(sp)
   6:	ec26                	sd	s1,24(sp)
   8:	e84a                	sd	s2,16(sp)
   a:	e44e                	sd	s3,8(sp)
   c:	1800                	addi	s0,sp,48
   e:	84aa                	mv	s1,a0
  static char buf[DIRSIZ+1];
  char *p;

  // Find first character after last slash.
  for(p=path+strlen(path); p >= path && *p != '/'; p--)
  10:	00000097          	auipc	ra,0x0
  14:	3ce080e7          	jalr	974(ra) # 3de <strlen>
  18:	02051793          	slli	a5,a0,0x20
  1c:	9381                	srli	a5,a5,0x20
  1e:	97a6                	add	a5,a5,s1
  20:	02f00693          	li	a3,47
  24:	0097e963          	bltu	a5,s1,36 <fmtname+0x36>
  28:	0007c703          	lbu	a4,0(a5)
  2c:	00d70563          	beq	a4,a3,36 <fmtname+0x36>
  30:	17fd                	addi	a5,a5,-1
  32:	fe97fbe3          	bgeu	a5,s1,28 <fmtname+0x28>
    ;
  p++;
  36:	00178493          	addi	s1,a5,1

  // Return blank-padded name.
  if(strlen(p) >= DIRSIZ)
  3a:	8526                	mv	a0,s1
  3c:	00000097          	auipc	ra,0x0
  40:	3a2080e7          	jalr	930(ra) # 3de <strlen>
  44:	2501                	sext.w	a0,a0
  46:	47b5                	li	a5,13
  48:	00a7fa63          	bgeu	a5,a0,5c <fmtname+0x5c>
    return p;
  memmove(buf, p, strlen(p));
  memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
  return buf;
}
  4c:	8526                	mv	a0,s1
  4e:	70a2                	ld	ra,40(sp)
  50:	7402                	ld	s0,32(sp)
  52:	64e2                	ld	s1,24(sp)
  54:	6942                	ld	s2,16(sp)
  56:	69a2                	ld	s3,8(sp)
  58:	6145                	addi	sp,sp,48
  5a:	8082                	ret
  memmove(buf, p, strlen(p));
  5c:	8526                	mv	a0,s1
  5e:	00000097          	auipc	ra,0x0
  62:	380080e7          	jalr	896(ra) # 3de <strlen>
  66:	00001997          	auipc	s3,0x1
  6a:	bba98993          	addi	s3,s3,-1094 # c20 <buf.0>
  6e:	0005061b          	sext.w	a2,a0
  72:	85a6                	mv	a1,s1
  74:	854e                	mv	a0,s3
  76:	00000097          	auipc	ra,0x0
  7a:	4da080e7          	jalr	1242(ra) # 550 <memmove>
  memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
  7e:	8526                	mv	a0,s1
  80:	00000097          	auipc	ra,0x0
  84:	35e080e7          	jalr	862(ra) # 3de <strlen>
  88:	0005091b          	sext.w	s2,a0
  8c:	8526                	mv	a0,s1
  8e:	00000097          	auipc	ra,0x0
  92:	350080e7          	jalr	848(ra) # 3de <strlen>
  96:	1902                	slli	s2,s2,0x20
  98:	02095913          	srli	s2,s2,0x20
  9c:	4639                	li	a2,14
  9e:	9e09                	subw	a2,a2,a0
  a0:	02000593          	li	a1,32
  a4:	01298533          	add	a0,s3,s2
  a8:	00000097          	auipc	ra,0x0
  ac:	360080e7          	jalr	864(ra) # 408 <memset>
  return buf;
  b0:	84ce                	mv	s1,s3
  b2:	bf69                	j	4c <fmtname+0x4c>

00000000000000b4 <printbtn>:

void
printbtn(int fd, struct btreenode *btn, char *p, char *buf, struct stat *st){
  b4:	d3010113          	addi	sp,sp,-720
  b8:	2c113423          	sd	ra,712(sp)
  bc:	2c813023          	sd	s0,704(sp)
  c0:	2a913c23          	sd	s1,696(sp)
  c4:	2b213823          	sd	s2,688(sp)
  c8:	2b313423          	sd	s3,680(sp)
  cc:	2b413023          	sd	s4,672(sp)
  d0:	29513c23          	sd	s5,664(sp)
  d4:	29613823          	sd	s6,656(sp)
  d8:	29713423          	sd	s7,648(sp)
  dc:	29813023          	sd	s8,640(sp)
  e0:	27913c23          	sd	s9,632(sp)
  e4:	0d80                	addi	s0,sp,720
  e6:	8baa                	mv	s7,a0
  e8:	8aae                	mv	s5,a1
  ea:	8a32                	mv	s4,a2
  ec:	89b6                	mv	s3,a3
  ee:	84ba                	mv	s1,a4
  for(int i = 0; i < btn->numkeys; i++){
  f0:	41dc                	lw	a5,4(a1)
  f2:	cfad                	beqz	a5,16c <printbtn+0xb8>
  f4:	00e58913          	addi	s2,a1,14
  f8:	4b01                	li	s6,0
    memmove(p, btn->keys[i].name, DIRSIZ);
    p[DIRSIZ] = 0;
    if(stat(buf, st) < 0){
      printf("ls: cannot stat %s\n", buf);
  fa:	00001c97          	auipc	s9,0x1
  fe:	a36c8c93          	addi	s9,s9,-1482 # b30 <malloc+0xec>
    }
    printf("%s %d %d %d\n", fmtname(buf), st->type, st->ino, st->size);
 102:	00001c17          	auipc	s8,0x1
 106:	a46c0c13          	addi	s8,s8,-1466 # b48 <malloc+0x104>
 10a:	a80d                	j	13c <printbtn+0x88>
 10c:	854e                	mv	a0,s3
 10e:	00000097          	auipc	ra,0x0
 112:	ef2080e7          	jalr	-270(ra) # 0 <fmtname>
 116:	85aa                	mv	a1,a0
 118:	6898                	ld	a4,16(s1)
 11a:	40d4                	lw	a3,4(s1)
 11c:	00849603          	lh	a2,8(s1)
 120:	8562                	mv	a0,s8
 122:	00001097          	auipc	ra,0x1
 126:	86a080e7          	jalr	-1942(ra) # 98c <printf>
  for(int i = 0; i < btn->numkeys; i++){
 12a:	001b079b          	addiw	a5,s6,1
 12e:	00078b1b          	sext.w	s6,a5
 132:	0941                	addi	s2,s2,16
 134:	004aa703          	lw	a4,4(s5)
 138:	02eb7a63          	bgeu	s6,a4,16c <printbtn+0xb8>
    memmove(p, btn->keys[i].name, DIRSIZ);
 13c:	4639                	li	a2,14
 13e:	85ca                	mv	a1,s2
 140:	8552                	mv	a0,s4
 142:	00000097          	auipc	ra,0x0
 146:	40e080e7          	jalr	1038(ra) # 550 <memmove>
    p[DIRSIZ] = 0;
 14a:	000a0723          	sb	zero,14(s4)
    if(stat(buf, st) < 0){
 14e:	85a6                	mv	a1,s1
 150:	854e                	mv	a0,s3
 152:	00000097          	auipc	ra,0x0
 156:	370080e7          	jalr	880(ra) # 4c2 <stat>
 15a:	fa0559e3          	bgez	a0,10c <printbtn+0x58>
      printf("ls: cannot stat %s\n", buf);
 15e:	85ce                	mv	a1,s3
 160:	8566                	mv	a0,s9
 162:	00001097          	auipc	ra,0x1
 166:	82a080e7          	jalr	-2006(ra) # 98c <printf>
 16a:	b74d                	j	10c <printbtn+0x58>
  }
  for(int i = 0; i < btn->childnum; i++){
 16c:	008aa783          	lw	a5,8(s5)
 170:	c3b1                	beqz	a5,1b4 <printbtn+0x100>
 172:	1eca8913          	addi	s2,s5,492
 176:	4b01                	li	s6,0
    struct btreenode newbtn;
    // 这里修改了newbtn
    rbtn(fd, &newbtn, sizeof(struct btreenode), btn->children[i]);
 178:	00092683          	lw	a3,0(s2)
 17c:	26c00613          	li	a2,620
 180:	d3040593          	addi	a1,s0,-720
 184:	855e                	mv	a0,s7
 186:	00000097          	auipc	ra,0x0
 18a:	51c080e7          	jalr	1308(ra) # 6a2 <rbtn>
    printbtn(fd, &newbtn, p, buf, st);
 18e:	8726                	mv	a4,s1
 190:	86ce                	mv	a3,s3
 192:	8652                	mv	a2,s4
 194:	d3040593          	addi	a1,s0,-720
 198:	855e                	mv	a0,s7
 19a:	00000097          	auipc	ra,0x0
 19e:	f1a080e7          	jalr	-230(ra) # b4 <printbtn>
  for(int i = 0; i < btn->childnum; i++){
 1a2:	001b079b          	addiw	a5,s6,1
 1a6:	00078b1b          	sext.w	s6,a5
 1aa:	0911                	addi	s2,s2,4
 1ac:	008aa703          	lw	a4,8(s5)
 1b0:	fceb64e3          	bltu	s6,a4,178 <printbtn+0xc4>
  }
}
 1b4:	2c813083          	ld	ra,712(sp)
 1b8:	2c013403          	ld	s0,704(sp)
 1bc:	2b813483          	ld	s1,696(sp)
 1c0:	2b013903          	ld	s2,688(sp)
 1c4:	2a813983          	ld	s3,680(sp)
 1c8:	2a013a03          	ld	s4,672(sp)
 1cc:	29813a83          	ld	s5,664(sp)
 1d0:	29013b03          	ld	s6,656(sp)
 1d4:	28813b83          	ld	s7,648(sp)
 1d8:	28013c03          	ld	s8,640(sp)
 1dc:	27813c83          	ld	s9,632(sp)
 1e0:	2d010113          	addi	sp,sp,720
 1e4:	8082                	ret

00000000000001e6 <ls>:

void
ls(char *path)
{
 1e6:	b5010113          	addi	sp,sp,-1200
 1ea:	4a113423          	sd	ra,1192(sp)
 1ee:	4a813023          	sd	s0,1184(sp)
 1f2:	48913c23          	sd	s1,1176(sp)
 1f6:	49213823          	sd	s2,1168(sp)
 1fa:	4b010413          	addi	s0,sp,1200
 1fe:	892a                	mv	s2,a0
  char buf[512], *p;
  int fd;
  // struct dirent de;
  struct stat st;

  if((fd = open(path, 0)) < 0){
 200:	4581                	li	a1,0
 202:	00000097          	auipc	ra,0x0
 206:	440080e7          	jalr	1088(ra) # 642 <open>
 20a:	06054963          	bltz	a0,27c <ls+0x96>
 20e:	84aa                	mv	s1,a0
    fprintf(2, "ls: cannot open %s\n", path);
    return;
  }

  if(fstat(fd, &st) < 0){
 210:	dc840593          	addi	a1,s0,-568
 214:	00000097          	auipc	ra,0x0
 218:	446080e7          	jalr	1094(ra) # 65a <fstat>
 21c:	06054b63          	bltz	a0,292 <ls+0xac>
    fprintf(2, "ls: cannot stat %s\n", path);
    close(fd);
    return;
  }

  switch(st.type){
 220:	dd041783          	lh	a5,-560(s0)
 224:	0007869b          	sext.w	a3,a5
 228:	4705                	li	a4,1
 22a:	08e68463          	beq	a3,a4,2b2 <ls+0xcc>
 22e:	4709                	li	a4,2
 230:	02e69663          	bne	a3,a4,25c <ls+0x76>
  case T_FILE:
    printf("%s %d %d %l\n", fmtname(path), st.type, st.ino, st.size);
 234:	854a                	mv	a0,s2
 236:	00000097          	auipc	ra,0x0
 23a:	dca080e7          	jalr	-566(ra) # 0 <fmtname>
 23e:	85aa                	mv	a1,a0
 240:	dd843703          	ld	a4,-552(s0)
 244:	dcc42683          	lw	a3,-564(s0)
 248:	dd041603          	lh	a2,-560(s0)
 24c:	00001517          	auipc	a0,0x1
 250:	92450513          	addi	a0,a0,-1756 # b70 <malloc+0x12c>
 254:	00000097          	auipc	ra,0x0
 258:	738080e7          	jalr	1848(ra) # 98c <printf>
      // 输出根节点中的目录项，继续寻找子节点并输出
      printbtn(fd, &btn, p, buf, &st);
    }
    break;
  }
  close(fd);
 25c:	8526                	mv	a0,s1
 25e:	00000097          	auipc	ra,0x0
 262:	3cc080e7          	jalr	972(ra) # 62a <close>
}
 266:	4a813083          	ld	ra,1192(sp)
 26a:	4a013403          	ld	s0,1184(sp)
 26e:	49813483          	ld	s1,1176(sp)
 272:	49013903          	ld	s2,1168(sp)
 276:	4b010113          	addi	sp,sp,1200
 27a:	8082                	ret
    fprintf(2, "ls: cannot open %s\n", path);
 27c:	864a                	mv	a2,s2
 27e:	00001597          	auipc	a1,0x1
 282:	8da58593          	addi	a1,a1,-1830 # b58 <malloc+0x114>
 286:	4509                	li	a0,2
 288:	00000097          	auipc	ra,0x0
 28c:	6d6080e7          	jalr	1750(ra) # 95e <fprintf>
    return;
 290:	bfd9                	j	266 <ls+0x80>
    fprintf(2, "ls: cannot stat %s\n", path);
 292:	864a                	mv	a2,s2
 294:	00001597          	auipc	a1,0x1
 298:	89c58593          	addi	a1,a1,-1892 # b30 <malloc+0xec>
 29c:	4509                	li	a0,2
 29e:	00000097          	auipc	ra,0x0
 2a2:	6c0080e7          	jalr	1728(ra) # 95e <fprintf>
    close(fd);
 2a6:	8526                	mv	a0,s1
 2a8:	00000097          	auipc	ra,0x0
 2ac:	382080e7          	jalr	898(ra) # 62a <close>
    return;
 2b0:	bf5d                	j	266 <ls+0x80>
    if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
 2b2:	854a                	mv	a0,s2
 2b4:	00000097          	auipc	ra,0x0
 2b8:	12a080e7          	jalr	298(ra) # 3de <strlen>
 2bc:	2541                	addiw	a0,a0,16
 2be:	20000793          	li	a5,512
 2c2:	00a7fb63          	bgeu	a5,a0,2d8 <ls+0xf2>
      printf("ls: path too long\n");
 2c6:	00001517          	auipc	a0,0x1
 2ca:	8ba50513          	addi	a0,a0,-1862 # b80 <malloc+0x13c>
 2ce:	00000097          	auipc	ra,0x0
 2d2:	6be080e7          	jalr	1726(ra) # 98c <printf>
      break;
 2d6:	b759                	j	25c <ls+0x76>
    strcpy(buf, path);
 2d8:	85ca                	mv	a1,s2
 2da:	de040513          	addi	a0,s0,-544
 2de:	00000097          	auipc	ra,0x0
 2e2:	0b8080e7          	jalr	184(ra) # 396 <strcpy>
    p = buf+strlen(buf);
 2e6:	de040513          	addi	a0,s0,-544
 2ea:	00000097          	auipc	ra,0x0
 2ee:	0f4080e7          	jalr	244(ra) # 3de <strlen>
 2f2:	1502                	slli	a0,a0,0x20
 2f4:	9101                	srli	a0,a0,0x20
 2f6:	de040793          	addi	a5,s0,-544
 2fa:	00a78933          	add	s2,a5,a0
    *p++ = '/';
 2fe:	02f00793          	li	a5,47
 302:	00f90023          	sb	a5,0(s2)
    if(read(fd, &btn, sizeof(struct btreenode)) == sizeof(struct btreenode)){
 306:	26c00613          	li	a2,620
 30a:	b5840593          	addi	a1,s0,-1192
 30e:	8526                	mv	a0,s1
 310:	00000097          	auipc	ra,0x0
 314:	30a080e7          	jalr	778(ra) # 61a <read>
 318:	26c00793          	li	a5,620
 31c:	f4f510e3          	bne	a0,a5,25c <ls+0x76>
      printbtn(fd, &btn, p, buf, &st);
 320:	dc840713          	addi	a4,s0,-568
 324:	de040693          	addi	a3,s0,-544
 328:	00190613          	addi	a2,s2,1
 32c:	b5840593          	addi	a1,s0,-1192
 330:	8526                	mv	a0,s1
 332:	00000097          	auipc	ra,0x0
 336:	d82080e7          	jalr	-638(ra) # b4 <printbtn>
 33a:	b70d                	j	25c <ls+0x76>

000000000000033c <main>:

int
main(int argc, char *argv[])
{
 33c:	1101                	addi	sp,sp,-32
 33e:	ec06                	sd	ra,24(sp)
 340:	e822                	sd	s0,16(sp)
 342:	e426                	sd	s1,8(sp)
 344:	e04a                	sd	s2,0(sp)
 346:	1000                	addi	s0,sp,32
  int i;

  if(argc < 2){
 348:	4785                	li	a5,1
 34a:	02a7d963          	bge	a5,a0,37c <main+0x40>
 34e:	00858493          	addi	s1,a1,8
 352:	ffe5091b          	addiw	s2,a0,-2
 356:	02091793          	slli	a5,s2,0x20
 35a:	01d7d913          	srli	s2,a5,0x1d
 35e:	05c1                	addi	a1,a1,16
 360:	992e                	add	s2,s2,a1
    ls(".");
    exit(0);
  }
  for(i=1; i<argc; i++)
    ls(argv[i]);
 362:	6088                	ld	a0,0(s1)
 364:	00000097          	auipc	ra,0x0
 368:	e82080e7          	jalr	-382(ra) # 1e6 <ls>
  for(i=1; i<argc; i++)
 36c:	04a1                	addi	s1,s1,8
 36e:	ff249ae3          	bne	s1,s2,362 <main+0x26>
  exit(0);
 372:	4501                	li	a0,0
 374:	00000097          	auipc	ra,0x0
 378:	28e080e7          	jalr	654(ra) # 602 <exit>
    ls(".");
 37c:	00001517          	auipc	a0,0x1
 380:	81c50513          	addi	a0,a0,-2020 # b98 <malloc+0x154>
 384:	00000097          	auipc	ra,0x0
 388:	e62080e7          	jalr	-414(ra) # 1e6 <ls>
    exit(0);
 38c:	4501                	li	a0,0
 38e:	00000097          	auipc	ra,0x0
 392:	274080e7          	jalr	628(ra) # 602 <exit>

0000000000000396 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"

char*
strcpy(char *s, const char *t)
{
 396:	1141                	addi	sp,sp,-16
 398:	e422                	sd	s0,8(sp)
 39a:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 39c:	87aa                	mv	a5,a0
 39e:	0585                	addi	a1,a1,1
 3a0:	0785                	addi	a5,a5,1
 3a2:	fff5c703          	lbu	a4,-1(a1)
 3a6:	fee78fa3          	sb	a4,-1(a5)
 3aa:	fb75                	bnez	a4,39e <strcpy+0x8>
    ;
  return os;
}
 3ac:	6422                	ld	s0,8(sp)
 3ae:	0141                	addi	sp,sp,16
 3b0:	8082                	ret

00000000000003b2 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 3b2:	1141                	addi	sp,sp,-16
 3b4:	e422                	sd	s0,8(sp)
 3b6:	0800                	addi	s0,sp,16
  while(*p && *p == *q)
 3b8:	00054783          	lbu	a5,0(a0)
 3bc:	cb91                	beqz	a5,3d0 <strcmp+0x1e>
 3be:	0005c703          	lbu	a4,0(a1)
 3c2:	00f71763          	bne	a4,a5,3d0 <strcmp+0x1e>
    p++, q++;
 3c6:	0505                	addi	a0,a0,1
 3c8:	0585                	addi	a1,a1,1
  while(*p && *p == *q)
 3ca:	00054783          	lbu	a5,0(a0)
 3ce:	fbe5                	bnez	a5,3be <strcmp+0xc>
  return (uchar)*p - (uchar)*q;
 3d0:	0005c503          	lbu	a0,0(a1)
}
 3d4:	40a7853b          	subw	a0,a5,a0
 3d8:	6422                	ld	s0,8(sp)
 3da:	0141                	addi	sp,sp,16
 3dc:	8082                	ret

00000000000003de <strlen>:

uint
strlen(const char *s)
{
 3de:	1141                	addi	sp,sp,-16
 3e0:	e422                	sd	s0,8(sp)
 3e2:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
 3e4:	00054783          	lbu	a5,0(a0)
 3e8:	cf91                	beqz	a5,404 <strlen+0x26>
 3ea:	0505                	addi	a0,a0,1
 3ec:	87aa                	mv	a5,a0
 3ee:	4685                	li	a3,1
 3f0:	9e89                	subw	a3,a3,a0
 3f2:	00f6853b          	addw	a0,a3,a5
 3f6:	0785                	addi	a5,a5,1
 3f8:	fff7c703          	lbu	a4,-1(a5)
 3fc:	fb7d                	bnez	a4,3f2 <strlen+0x14>
    ;
  return n;
}
 3fe:	6422                	ld	s0,8(sp)
 400:	0141                	addi	sp,sp,16
 402:	8082                	ret
  for(n = 0; s[n]; n++)
 404:	4501                	li	a0,0
 406:	bfe5                	j	3fe <strlen+0x20>

0000000000000408 <memset>:

void*
memset(void *dst, int c, uint n)
{
 408:	1141                	addi	sp,sp,-16
 40a:	e422                	sd	s0,8(sp)
 40c:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
 40e:	ca19                	beqz	a2,424 <memset+0x1c>
 410:	87aa                	mv	a5,a0
 412:	1602                	slli	a2,a2,0x20
 414:	9201                	srli	a2,a2,0x20
 416:	00a60733          	add	a4,a2,a0
    cdst[i] = c;
 41a:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
 41e:	0785                	addi	a5,a5,1
 420:	fee79de3          	bne	a5,a4,41a <memset+0x12>
  }
  return dst;
}
 424:	6422                	ld	s0,8(sp)
 426:	0141                	addi	sp,sp,16
 428:	8082                	ret

000000000000042a <strchr>:

char*
strchr(const char *s, char c)
{
 42a:	1141                	addi	sp,sp,-16
 42c:	e422                	sd	s0,8(sp)
 42e:	0800                	addi	s0,sp,16
  for(; *s; s++)
 430:	00054783          	lbu	a5,0(a0)
 434:	cb99                	beqz	a5,44a <strchr+0x20>
    if(*s == c)
 436:	00f58763          	beq	a1,a5,444 <strchr+0x1a>
  for(; *s; s++)
 43a:	0505                	addi	a0,a0,1
 43c:	00054783          	lbu	a5,0(a0)
 440:	fbfd                	bnez	a5,436 <strchr+0xc>
      return (char*)s;
  return 0;
 442:	4501                	li	a0,0
}
 444:	6422                	ld	s0,8(sp)
 446:	0141                	addi	sp,sp,16
 448:	8082                	ret
  return 0;
 44a:	4501                	li	a0,0
 44c:	bfe5                	j	444 <strchr+0x1a>

000000000000044e <gets>:

char*
gets(char *buf, int max)
{
 44e:	711d                	addi	sp,sp,-96
 450:	ec86                	sd	ra,88(sp)
 452:	e8a2                	sd	s0,80(sp)
 454:	e4a6                	sd	s1,72(sp)
 456:	e0ca                	sd	s2,64(sp)
 458:	fc4e                	sd	s3,56(sp)
 45a:	f852                	sd	s4,48(sp)
 45c:	f456                	sd	s5,40(sp)
 45e:	f05a                	sd	s6,32(sp)
 460:	ec5e                	sd	s7,24(sp)
 462:	1080                	addi	s0,sp,96
 464:	8baa                	mv	s7,a0
 466:	8a2e                	mv	s4,a1
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 468:	892a                	mv	s2,a0
 46a:	4481                	li	s1,0
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 46c:	4aa9                	li	s5,10
 46e:	4b35                	li	s6,13
  for(i=0; i+1 < max; ){
 470:	89a6                	mv	s3,s1
 472:	2485                	addiw	s1,s1,1
 474:	0344d863          	bge	s1,s4,4a4 <gets+0x56>
    cc = read(0, &c, 1);
 478:	4605                	li	a2,1
 47a:	faf40593          	addi	a1,s0,-81
 47e:	4501                	li	a0,0
 480:	00000097          	auipc	ra,0x0
 484:	19a080e7          	jalr	410(ra) # 61a <read>
    if(cc < 1)
 488:	00a05e63          	blez	a0,4a4 <gets+0x56>
    buf[i++] = c;
 48c:	faf44783          	lbu	a5,-81(s0)
 490:	00f90023          	sb	a5,0(s2)
    if(c == '\n' || c == '\r')
 494:	01578763          	beq	a5,s5,4a2 <gets+0x54>
 498:	0905                	addi	s2,s2,1
 49a:	fd679be3          	bne	a5,s6,470 <gets+0x22>
  for(i=0; i+1 < max; ){
 49e:	89a6                	mv	s3,s1
 4a0:	a011                	j	4a4 <gets+0x56>
 4a2:	89a6                	mv	s3,s1
      break;
  }
  buf[i] = '\0';
 4a4:	99de                	add	s3,s3,s7
 4a6:	00098023          	sb	zero,0(s3)
  return buf;
}
 4aa:	855e                	mv	a0,s7
 4ac:	60e6                	ld	ra,88(sp)
 4ae:	6446                	ld	s0,80(sp)
 4b0:	64a6                	ld	s1,72(sp)
 4b2:	6906                	ld	s2,64(sp)
 4b4:	79e2                	ld	s3,56(sp)
 4b6:	7a42                	ld	s4,48(sp)
 4b8:	7aa2                	ld	s5,40(sp)
 4ba:	7b02                	ld	s6,32(sp)
 4bc:	6be2                	ld	s7,24(sp)
 4be:	6125                	addi	sp,sp,96
 4c0:	8082                	ret

00000000000004c2 <stat>:

int
stat(const char *n, struct stat *st)
{
 4c2:	1101                	addi	sp,sp,-32
 4c4:	ec06                	sd	ra,24(sp)
 4c6:	e822                	sd	s0,16(sp)
 4c8:	e426                	sd	s1,8(sp)
 4ca:	e04a                	sd	s2,0(sp)
 4cc:	1000                	addi	s0,sp,32
 4ce:	892e                	mv	s2,a1
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 4d0:	4581                	li	a1,0
 4d2:	00000097          	auipc	ra,0x0
 4d6:	170080e7          	jalr	368(ra) # 642 <open>
  if(fd < 0)
 4da:	02054563          	bltz	a0,504 <stat+0x42>
 4de:	84aa                	mv	s1,a0
    return -1;
  r = fstat(fd, st);
 4e0:	85ca                	mv	a1,s2
 4e2:	00000097          	auipc	ra,0x0
 4e6:	178080e7          	jalr	376(ra) # 65a <fstat>
 4ea:	892a                	mv	s2,a0
  close(fd);
 4ec:	8526                	mv	a0,s1
 4ee:	00000097          	auipc	ra,0x0
 4f2:	13c080e7          	jalr	316(ra) # 62a <close>
  return r;
}
 4f6:	854a                	mv	a0,s2
 4f8:	60e2                	ld	ra,24(sp)
 4fa:	6442                	ld	s0,16(sp)
 4fc:	64a2                	ld	s1,8(sp)
 4fe:	6902                	ld	s2,0(sp)
 500:	6105                	addi	sp,sp,32
 502:	8082                	ret
    return -1;
 504:	597d                	li	s2,-1
 506:	bfc5                	j	4f6 <stat+0x34>

0000000000000508 <atoi>:

int
atoi(const char *s)
{
 508:	1141                	addi	sp,sp,-16
 50a:	e422                	sd	s0,8(sp)
 50c:	0800                	addi	s0,sp,16
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 50e:	00054683          	lbu	a3,0(a0)
 512:	fd06879b          	addiw	a5,a3,-48
 516:	0ff7f793          	zext.b	a5,a5
 51a:	4625                	li	a2,9
 51c:	02f66863          	bltu	a2,a5,54c <atoi+0x44>
 520:	872a                	mv	a4,a0
  n = 0;
 522:	4501                	li	a0,0
    n = n*10 + *s++ - '0';
 524:	0705                	addi	a4,a4,1
 526:	0025179b          	slliw	a5,a0,0x2
 52a:	9fa9                	addw	a5,a5,a0
 52c:	0017979b          	slliw	a5,a5,0x1
 530:	9fb5                	addw	a5,a5,a3
 532:	fd07851b          	addiw	a0,a5,-48
  while('0' <= *s && *s <= '9')
 536:	00074683          	lbu	a3,0(a4)
 53a:	fd06879b          	addiw	a5,a3,-48
 53e:	0ff7f793          	zext.b	a5,a5
 542:	fef671e3          	bgeu	a2,a5,524 <atoi+0x1c>
  return n;
}
 546:	6422                	ld	s0,8(sp)
 548:	0141                	addi	sp,sp,16
 54a:	8082                	ret
  n = 0;
 54c:	4501                	li	a0,0
 54e:	bfe5                	j	546 <atoi+0x3e>

0000000000000550 <memmove>:

void*
memmove(void *vdst, const void *vsrc, int n)
{
 550:	1141                	addi	sp,sp,-16
 552:	e422                	sd	s0,8(sp)
 554:	0800                	addi	s0,sp,16
  char *dst;
  const char *src;

  dst = vdst;
  src = vsrc;
  if (src > dst) {
 556:	02b57463          	bgeu	a0,a1,57e <memmove+0x2e>
    while(n-- > 0)
 55a:	00c05f63          	blez	a2,578 <memmove+0x28>
 55e:	1602                	slli	a2,a2,0x20
 560:	9201                	srli	a2,a2,0x20
 562:	00c507b3          	add	a5,a0,a2
  dst = vdst;
 566:	872a                	mv	a4,a0
      *dst++ = *src++;
 568:	0585                	addi	a1,a1,1
 56a:	0705                	addi	a4,a4,1
 56c:	fff5c683          	lbu	a3,-1(a1)
 570:	fed70fa3          	sb	a3,-1(a4)
    while(n-- > 0)
 574:	fee79ae3          	bne	a5,a4,568 <memmove+0x18>
    src += n;
    while(n-- > 0)
      *--dst = *--src;
  }
  return vdst;
}
 578:	6422                	ld	s0,8(sp)
 57a:	0141                	addi	sp,sp,16
 57c:	8082                	ret
    dst += n;
 57e:	00c50733          	add	a4,a0,a2
    src += n;
 582:	95b2                	add	a1,a1,a2
    while(n-- > 0)
 584:	fec05ae3          	blez	a2,578 <memmove+0x28>
 588:	fff6079b          	addiw	a5,a2,-1
 58c:	1782                	slli	a5,a5,0x20
 58e:	9381                	srli	a5,a5,0x20
 590:	fff7c793          	not	a5,a5
 594:	97ba                	add	a5,a5,a4
      *--dst = *--src;
 596:	15fd                	addi	a1,a1,-1
 598:	177d                	addi	a4,a4,-1
 59a:	0005c683          	lbu	a3,0(a1)
 59e:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
 5a2:	fee79ae3          	bne	a5,a4,596 <memmove+0x46>
 5a6:	bfc9                	j	578 <memmove+0x28>

00000000000005a8 <memcmp>:

int
memcmp(const void *s1, const void *s2, uint n)
{
 5a8:	1141                	addi	sp,sp,-16
 5aa:	e422                	sd	s0,8(sp)
 5ac:	0800                	addi	s0,sp,16
  const char *p1 = s1, *p2 = s2;
  while (n-- > 0) {
 5ae:	ca05                	beqz	a2,5de <memcmp+0x36>
 5b0:	fff6069b          	addiw	a3,a2,-1
 5b4:	1682                	slli	a3,a3,0x20
 5b6:	9281                	srli	a3,a3,0x20
 5b8:	0685                	addi	a3,a3,1
 5ba:	96aa                	add	a3,a3,a0
    if (*p1 != *p2) {
 5bc:	00054783          	lbu	a5,0(a0)
 5c0:	0005c703          	lbu	a4,0(a1)
 5c4:	00e79863          	bne	a5,a4,5d4 <memcmp+0x2c>
      return *p1 - *p2;
    }
    p1++;
 5c8:	0505                	addi	a0,a0,1
    p2++;
 5ca:	0585                	addi	a1,a1,1
  while (n-- > 0) {
 5cc:	fed518e3          	bne	a0,a3,5bc <memcmp+0x14>
  }
  return 0;
 5d0:	4501                	li	a0,0
 5d2:	a019                	j	5d8 <memcmp+0x30>
      return *p1 - *p2;
 5d4:	40e7853b          	subw	a0,a5,a4
}
 5d8:	6422                	ld	s0,8(sp)
 5da:	0141                	addi	sp,sp,16
 5dc:	8082                	ret
  return 0;
 5de:	4501                	li	a0,0
 5e0:	bfe5                	j	5d8 <memcmp+0x30>

00000000000005e2 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 5e2:	1141                	addi	sp,sp,-16
 5e4:	e406                	sd	ra,8(sp)
 5e6:	e022                	sd	s0,0(sp)
 5e8:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
 5ea:	00000097          	auipc	ra,0x0
 5ee:	f66080e7          	jalr	-154(ra) # 550 <memmove>
}
 5f2:	60a2                	ld	ra,8(sp)
 5f4:	6402                	ld	s0,0(sp)
 5f6:	0141                	addi	sp,sp,16
 5f8:	8082                	ret

00000000000005fa <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
 li a7, SYS_fork
 5fa:	4885                	li	a7,1
 ecall
 5fc:	00000073          	ecall
 ret
 600:	8082                	ret

0000000000000602 <exit>:
.global exit
exit:
 li a7, SYS_exit
 602:	4889                	li	a7,2
 ecall
 604:	00000073          	ecall
 ret
 608:	8082                	ret

000000000000060a <wait>:
.global wait
wait:
 li a7, SYS_wait
 60a:	488d                	li	a7,3
 ecall
 60c:	00000073          	ecall
 ret
 610:	8082                	ret

0000000000000612 <pipe>:
.global pipe
pipe:
 li a7, SYS_pipe
 612:	4891                	li	a7,4
 ecall
 614:	00000073          	ecall
 ret
 618:	8082                	ret

000000000000061a <read>:
.global read
read:
 li a7, SYS_read
 61a:	4895                	li	a7,5
 ecall
 61c:	00000073          	ecall
 ret
 620:	8082                	ret

0000000000000622 <write>:
.global write
write:
 li a7, SYS_write
 622:	48c1                	li	a7,16
 ecall
 624:	00000073          	ecall
 ret
 628:	8082                	ret

000000000000062a <close>:
.global close
close:
 li a7, SYS_close
 62a:	48d5                	li	a7,21
 ecall
 62c:	00000073          	ecall
 ret
 630:	8082                	ret

0000000000000632 <kill>:
.global kill
kill:
 li a7, SYS_kill
 632:	4899                	li	a7,6
 ecall
 634:	00000073          	ecall
 ret
 638:	8082                	ret

000000000000063a <exec>:
.global exec
exec:
 li a7, SYS_exec
 63a:	489d                	li	a7,7
 ecall
 63c:	00000073          	ecall
 ret
 640:	8082                	ret

0000000000000642 <open>:
.global open
open:
 li a7, SYS_open
 642:	48bd                	li	a7,15
 ecall
 644:	00000073          	ecall
 ret
 648:	8082                	ret

000000000000064a <mknod>:
.global mknod
mknod:
 li a7, SYS_mknod
 64a:	48c5                	li	a7,17
 ecall
 64c:	00000073          	ecall
 ret
 650:	8082                	ret

0000000000000652 <unlink>:
.global unlink
unlink:
 li a7, SYS_unlink
 652:	48c9                	li	a7,18
 ecall
 654:	00000073          	ecall
 ret
 658:	8082                	ret

000000000000065a <fstat>:
.global fstat
fstat:
 li a7, SYS_fstat
 65a:	48a1                	li	a7,8
 ecall
 65c:	00000073          	ecall
 ret
 660:	8082                	ret

0000000000000662 <link>:
.global link
link:
 li a7, SYS_link
 662:	48cd                	li	a7,19
 ecall
 664:	00000073          	ecall
 ret
 668:	8082                	ret

000000000000066a <mkdir>:
.global mkdir
mkdir:
 li a7, SYS_mkdir
 66a:	48d1                	li	a7,20
 ecall
 66c:	00000073          	ecall
 ret
 670:	8082                	ret

0000000000000672 <chdir>:
.global chdir
chdir:
 li a7, SYS_chdir
 672:	48a5                	li	a7,9
 ecall
 674:	00000073          	ecall
 ret
 678:	8082                	ret

000000000000067a <dup>:
.global dup
dup:
 li a7, SYS_dup
 67a:	48a9                	li	a7,10
 ecall
 67c:	00000073          	ecall
 ret
 680:	8082                	ret

0000000000000682 <getpid>:
.global getpid
getpid:
 li a7, SYS_getpid
 682:	48ad                	li	a7,11
 ecall
 684:	00000073          	ecall
 ret
 688:	8082                	ret

000000000000068a <sbrk>:
.global sbrk
sbrk:
 li a7, SYS_sbrk
 68a:	48b1                	li	a7,12
 ecall
 68c:	00000073          	ecall
 ret
 690:	8082                	ret

0000000000000692 <sleep>:
.global sleep
sleep:
 li a7, SYS_sleep
 692:	48b5                	li	a7,13
 ecall
 694:	00000073          	ecall
 ret
 698:	8082                	ret

000000000000069a <uptime>:
.global uptime
uptime:
 li a7, SYS_uptime
 69a:	48b9                	li	a7,14
 ecall
 69c:	00000073          	ecall
 ret
 6a0:	8082                	ret

00000000000006a2 <rbtn>:
.global rbtn
rbtn:
 li a7, SYS_rbtn
 6a2:	48d9                	li	a7,22
 ecall
 6a4:	00000073          	ecall
 ret
 6a8:	8082                	ret

00000000000006aa <symlink>:
.global symlink
symlink:
 li a7, SYS_symlink
 6aa:	48dd                	li	a7,23
 ecall
 6ac:	00000073          	ecall
 ret
 6b0:	8082                	ret

00000000000006b2 <putc>:

static char digits[] = "0123456789ABCDEF";

static void
putc(int fd, char c)
{
 6b2:	1101                	addi	sp,sp,-32
 6b4:	ec06                	sd	ra,24(sp)
 6b6:	e822                	sd	s0,16(sp)
 6b8:	1000                	addi	s0,sp,32
 6ba:	feb407a3          	sb	a1,-17(s0)
  write(fd, &c, 1);
 6be:	4605                	li	a2,1
 6c0:	fef40593          	addi	a1,s0,-17
 6c4:	00000097          	auipc	ra,0x0
 6c8:	f5e080e7          	jalr	-162(ra) # 622 <write>
}
 6cc:	60e2                	ld	ra,24(sp)
 6ce:	6442                	ld	s0,16(sp)
 6d0:	6105                	addi	sp,sp,32
 6d2:	8082                	ret

00000000000006d4 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 6d4:	7139                	addi	sp,sp,-64
 6d6:	fc06                	sd	ra,56(sp)
 6d8:	f822                	sd	s0,48(sp)
 6da:	f426                	sd	s1,40(sp)
 6dc:	f04a                	sd	s2,32(sp)
 6de:	ec4e                	sd	s3,24(sp)
 6e0:	0080                	addi	s0,sp,64
 6e2:	84aa                	mv	s1,a0
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 6e4:	c299                	beqz	a3,6ea <printint+0x16>
 6e6:	0805c963          	bltz	a1,778 <printint+0xa4>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 6ea:	2581                	sext.w	a1,a1
  neg = 0;
 6ec:	4881                	li	a7,0
 6ee:	fc040693          	addi	a3,s0,-64
  }

  i = 0;
 6f2:	4701                	li	a4,0
  do{
    buf[i++] = digits[x % base];
 6f4:	2601                	sext.w	a2,a2
 6f6:	00000517          	auipc	a0,0x0
 6fa:	50a50513          	addi	a0,a0,1290 # c00 <digits>
 6fe:	883a                	mv	a6,a4
 700:	2705                	addiw	a4,a4,1
 702:	02c5f7bb          	remuw	a5,a1,a2
 706:	1782                	slli	a5,a5,0x20
 708:	9381                	srli	a5,a5,0x20
 70a:	97aa                	add	a5,a5,a0
 70c:	0007c783          	lbu	a5,0(a5)
 710:	00f68023          	sb	a5,0(a3)
  }while((x /= base) != 0);
 714:	0005879b          	sext.w	a5,a1
 718:	02c5d5bb          	divuw	a1,a1,a2
 71c:	0685                	addi	a3,a3,1
 71e:	fec7f0e3          	bgeu	a5,a2,6fe <printint+0x2a>
  if(neg)
 722:	00088c63          	beqz	a7,73a <printint+0x66>
    buf[i++] = '-';
 726:	fd070793          	addi	a5,a4,-48
 72a:	00878733          	add	a4,a5,s0
 72e:	02d00793          	li	a5,45
 732:	fef70823          	sb	a5,-16(a4)
 736:	0028071b          	addiw	a4,a6,2

  while(--i >= 0)
 73a:	02e05863          	blez	a4,76a <printint+0x96>
 73e:	fc040793          	addi	a5,s0,-64
 742:	00e78933          	add	s2,a5,a4
 746:	fff78993          	addi	s3,a5,-1
 74a:	99ba                	add	s3,s3,a4
 74c:	377d                	addiw	a4,a4,-1
 74e:	1702                	slli	a4,a4,0x20
 750:	9301                	srli	a4,a4,0x20
 752:	40e989b3          	sub	s3,s3,a4
    putc(fd, buf[i]);
 756:	fff94583          	lbu	a1,-1(s2)
 75a:	8526                	mv	a0,s1
 75c:	00000097          	auipc	ra,0x0
 760:	f56080e7          	jalr	-170(ra) # 6b2 <putc>
  while(--i >= 0)
 764:	197d                	addi	s2,s2,-1
 766:	ff3918e3          	bne	s2,s3,756 <printint+0x82>
}
 76a:	70e2                	ld	ra,56(sp)
 76c:	7442                	ld	s0,48(sp)
 76e:	74a2                	ld	s1,40(sp)
 770:	7902                	ld	s2,32(sp)
 772:	69e2                	ld	s3,24(sp)
 774:	6121                	addi	sp,sp,64
 776:	8082                	ret
    x = -xx;
 778:	40b005bb          	negw	a1,a1
    neg = 1;
 77c:	4885                	li	a7,1
    x = -xx;
 77e:	bf85                	j	6ee <printint+0x1a>

0000000000000780 <vprintf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
 780:	7119                	addi	sp,sp,-128
 782:	fc86                	sd	ra,120(sp)
 784:	f8a2                	sd	s0,112(sp)
 786:	f4a6                	sd	s1,104(sp)
 788:	f0ca                	sd	s2,96(sp)
 78a:	ecce                	sd	s3,88(sp)
 78c:	e8d2                	sd	s4,80(sp)
 78e:	e4d6                	sd	s5,72(sp)
 790:	e0da                	sd	s6,64(sp)
 792:	fc5e                	sd	s7,56(sp)
 794:	f862                	sd	s8,48(sp)
 796:	f466                	sd	s9,40(sp)
 798:	f06a                	sd	s10,32(sp)
 79a:	ec6e                	sd	s11,24(sp)
 79c:	0100                	addi	s0,sp,128
  char *s;
  int c, i, state;

  state = 0;
  for(i = 0; fmt[i]; i++){
 79e:	0005c903          	lbu	s2,0(a1)
 7a2:	18090f63          	beqz	s2,940 <vprintf+0x1c0>
 7a6:	8aaa                	mv	s5,a0
 7a8:	8b32                	mv	s6,a2
 7aa:	00158493          	addi	s1,a1,1
  state = 0;
 7ae:	4981                	li	s3,0
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 7b0:	02500a13          	li	s4,37
 7b4:	4c55                	li	s8,21
 7b6:	00000c97          	auipc	s9,0x0
 7ba:	3f2c8c93          	addi	s9,s9,1010 # ba8 <malloc+0x164>
        printptr(fd, va_arg(ap, uint64));
      } else if(c == 's'){
        s = va_arg(ap, char*);
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 7be:	02800d93          	li	s11,40
  putc(fd, 'x');
 7c2:	4d41                	li	s10,16
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 7c4:	00000b97          	auipc	s7,0x0
 7c8:	43cb8b93          	addi	s7,s7,1084 # c00 <digits>
 7cc:	a839                	j	7ea <vprintf+0x6a>
        putc(fd, c);
 7ce:	85ca                	mv	a1,s2
 7d0:	8556                	mv	a0,s5
 7d2:	00000097          	auipc	ra,0x0
 7d6:	ee0080e7          	jalr	-288(ra) # 6b2 <putc>
 7da:	a019                	j	7e0 <vprintf+0x60>
    } else if(state == '%'){
 7dc:	01498d63          	beq	s3,s4,7f6 <vprintf+0x76>
  for(i = 0; fmt[i]; i++){
 7e0:	0485                	addi	s1,s1,1
 7e2:	fff4c903          	lbu	s2,-1(s1)
 7e6:	14090d63          	beqz	s2,940 <vprintf+0x1c0>
    if(state == 0){
 7ea:	fe0999e3          	bnez	s3,7dc <vprintf+0x5c>
      if(c == '%'){
 7ee:	ff4910e3          	bne	s2,s4,7ce <vprintf+0x4e>
        state = '%';
 7f2:	89d2                	mv	s3,s4
 7f4:	b7f5                	j	7e0 <vprintf+0x60>
      if(c == 'd'){
 7f6:	11490c63          	beq	s2,s4,90e <vprintf+0x18e>
 7fa:	f9d9079b          	addiw	a5,s2,-99
 7fe:	0ff7f793          	zext.b	a5,a5
 802:	10fc6e63          	bltu	s8,a5,91e <vprintf+0x19e>
 806:	f9d9079b          	addiw	a5,s2,-99
 80a:	0ff7f713          	zext.b	a4,a5
 80e:	10ec6863          	bltu	s8,a4,91e <vprintf+0x19e>
 812:	00271793          	slli	a5,a4,0x2
 816:	97e6                	add	a5,a5,s9
 818:	439c                	lw	a5,0(a5)
 81a:	97e6                	add	a5,a5,s9
 81c:	8782                	jr	a5
        printint(fd, va_arg(ap, int), 10, 1);
 81e:	008b0913          	addi	s2,s6,8
 822:	4685                	li	a3,1
 824:	4629                	li	a2,10
 826:	000b2583          	lw	a1,0(s6)
 82a:	8556                	mv	a0,s5
 82c:	00000097          	auipc	ra,0x0
 830:	ea8080e7          	jalr	-344(ra) # 6d4 <printint>
 834:	8b4a                	mv	s6,s2
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 836:	4981                	li	s3,0
 838:	b765                	j	7e0 <vprintf+0x60>
        printint(fd, va_arg(ap, uint64), 10, 0);
 83a:	008b0913          	addi	s2,s6,8
 83e:	4681                	li	a3,0
 840:	4629                	li	a2,10
 842:	000b2583          	lw	a1,0(s6)
 846:	8556                	mv	a0,s5
 848:	00000097          	auipc	ra,0x0
 84c:	e8c080e7          	jalr	-372(ra) # 6d4 <printint>
 850:	8b4a                	mv	s6,s2
      state = 0;
 852:	4981                	li	s3,0
 854:	b771                	j	7e0 <vprintf+0x60>
        printint(fd, va_arg(ap, int), 16, 0);
 856:	008b0913          	addi	s2,s6,8
 85a:	4681                	li	a3,0
 85c:	866a                	mv	a2,s10
 85e:	000b2583          	lw	a1,0(s6)
 862:	8556                	mv	a0,s5
 864:	00000097          	auipc	ra,0x0
 868:	e70080e7          	jalr	-400(ra) # 6d4 <printint>
 86c:	8b4a                	mv	s6,s2
      state = 0;
 86e:	4981                	li	s3,0
 870:	bf85                	j	7e0 <vprintf+0x60>
        printptr(fd, va_arg(ap, uint64));
 872:	008b0793          	addi	a5,s6,8
 876:	f8f43423          	sd	a5,-120(s0)
 87a:	000b3983          	ld	s3,0(s6)
  putc(fd, '0');
 87e:	03000593          	li	a1,48
 882:	8556                	mv	a0,s5
 884:	00000097          	auipc	ra,0x0
 888:	e2e080e7          	jalr	-466(ra) # 6b2 <putc>
  putc(fd, 'x');
 88c:	07800593          	li	a1,120
 890:	8556                	mv	a0,s5
 892:	00000097          	auipc	ra,0x0
 896:	e20080e7          	jalr	-480(ra) # 6b2 <putc>
 89a:	896a                	mv	s2,s10
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 89c:	03c9d793          	srli	a5,s3,0x3c
 8a0:	97de                	add	a5,a5,s7
 8a2:	0007c583          	lbu	a1,0(a5)
 8a6:	8556                	mv	a0,s5
 8a8:	00000097          	auipc	ra,0x0
 8ac:	e0a080e7          	jalr	-502(ra) # 6b2 <putc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
 8b0:	0992                	slli	s3,s3,0x4
 8b2:	397d                	addiw	s2,s2,-1
 8b4:	fe0914e3          	bnez	s2,89c <vprintf+0x11c>
        printptr(fd, va_arg(ap, uint64));
 8b8:	f8843b03          	ld	s6,-120(s0)
      state = 0;
 8bc:	4981                	li	s3,0
 8be:	b70d                	j	7e0 <vprintf+0x60>
        s = va_arg(ap, char*);
 8c0:	008b0913          	addi	s2,s6,8
 8c4:	000b3983          	ld	s3,0(s6)
        if(s == 0)
 8c8:	02098163          	beqz	s3,8ea <vprintf+0x16a>
        while(*s != 0){
 8cc:	0009c583          	lbu	a1,0(s3)
 8d0:	c5ad                	beqz	a1,93a <vprintf+0x1ba>
          putc(fd, *s);
 8d2:	8556                	mv	a0,s5
 8d4:	00000097          	auipc	ra,0x0
 8d8:	dde080e7          	jalr	-546(ra) # 6b2 <putc>
          s++;
 8dc:	0985                	addi	s3,s3,1
        while(*s != 0){
 8de:	0009c583          	lbu	a1,0(s3)
 8e2:	f9e5                	bnez	a1,8d2 <vprintf+0x152>
        s = va_arg(ap, char*);
 8e4:	8b4a                	mv	s6,s2
      state = 0;
 8e6:	4981                	li	s3,0
 8e8:	bde5                	j	7e0 <vprintf+0x60>
          s = "(null)";
 8ea:	00000997          	auipc	s3,0x0
 8ee:	2b698993          	addi	s3,s3,694 # ba0 <malloc+0x15c>
        while(*s != 0){
 8f2:	85ee                	mv	a1,s11
 8f4:	bff9                	j	8d2 <vprintf+0x152>
        putc(fd, va_arg(ap, uint));
 8f6:	008b0913          	addi	s2,s6,8
 8fa:	000b4583          	lbu	a1,0(s6)
 8fe:	8556                	mv	a0,s5
 900:	00000097          	auipc	ra,0x0
 904:	db2080e7          	jalr	-590(ra) # 6b2 <putc>
 908:	8b4a                	mv	s6,s2
      state = 0;
 90a:	4981                	li	s3,0
 90c:	bdd1                	j	7e0 <vprintf+0x60>
        putc(fd, c);
 90e:	85d2                	mv	a1,s4
 910:	8556                	mv	a0,s5
 912:	00000097          	auipc	ra,0x0
 916:	da0080e7          	jalr	-608(ra) # 6b2 <putc>
      state = 0;
 91a:	4981                	li	s3,0
 91c:	b5d1                	j	7e0 <vprintf+0x60>
        putc(fd, '%');
 91e:	85d2                	mv	a1,s4
 920:	8556                	mv	a0,s5
 922:	00000097          	auipc	ra,0x0
 926:	d90080e7          	jalr	-624(ra) # 6b2 <putc>
        putc(fd, c);
 92a:	85ca                	mv	a1,s2
 92c:	8556                	mv	a0,s5
 92e:	00000097          	auipc	ra,0x0
 932:	d84080e7          	jalr	-636(ra) # 6b2 <putc>
      state = 0;
 936:	4981                	li	s3,0
 938:	b565                	j	7e0 <vprintf+0x60>
        s = va_arg(ap, char*);
 93a:	8b4a                	mv	s6,s2
      state = 0;
 93c:	4981                	li	s3,0
 93e:	b54d                	j	7e0 <vprintf+0x60>
    }
  }
}
 940:	70e6                	ld	ra,120(sp)
 942:	7446                	ld	s0,112(sp)
 944:	74a6                	ld	s1,104(sp)
 946:	7906                	ld	s2,96(sp)
 948:	69e6                	ld	s3,88(sp)
 94a:	6a46                	ld	s4,80(sp)
 94c:	6aa6                	ld	s5,72(sp)
 94e:	6b06                	ld	s6,64(sp)
 950:	7be2                	ld	s7,56(sp)
 952:	7c42                	ld	s8,48(sp)
 954:	7ca2                	ld	s9,40(sp)
 956:	7d02                	ld	s10,32(sp)
 958:	6de2                	ld	s11,24(sp)
 95a:	6109                	addi	sp,sp,128
 95c:	8082                	ret

000000000000095e <fprintf>:

void
fprintf(int fd, const char *fmt, ...)
{
 95e:	715d                	addi	sp,sp,-80
 960:	ec06                	sd	ra,24(sp)
 962:	e822                	sd	s0,16(sp)
 964:	1000                	addi	s0,sp,32
 966:	e010                	sd	a2,0(s0)
 968:	e414                	sd	a3,8(s0)
 96a:	e818                	sd	a4,16(s0)
 96c:	ec1c                	sd	a5,24(s0)
 96e:	03043023          	sd	a6,32(s0)
 972:	03143423          	sd	a7,40(s0)
  va_list ap;

  va_start(ap, fmt);
 976:	fe843423          	sd	s0,-24(s0)
  vprintf(fd, fmt, ap);
 97a:	8622                	mv	a2,s0
 97c:	00000097          	auipc	ra,0x0
 980:	e04080e7          	jalr	-508(ra) # 780 <vprintf>
}
 984:	60e2                	ld	ra,24(sp)
 986:	6442                	ld	s0,16(sp)
 988:	6161                	addi	sp,sp,80
 98a:	8082                	ret

000000000000098c <printf>:

void
printf(const char *fmt, ...)
{
 98c:	711d                	addi	sp,sp,-96
 98e:	ec06                	sd	ra,24(sp)
 990:	e822                	sd	s0,16(sp)
 992:	1000                	addi	s0,sp,32
 994:	e40c                	sd	a1,8(s0)
 996:	e810                	sd	a2,16(s0)
 998:	ec14                	sd	a3,24(s0)
 99a:	f018                	sd	a4,32(s0)
 99c:	f41c                	sd	a5,40(s0)
 99e:	03043823          	sd	a6,48(s0)
 9a2:	03143c23          	sd	a7,56(s0)
  va_list ap;

  va_start(ap, fmt);
 9a6:	00840613          	addi	a2,s0,8
 9aa:	fec43423          	sd	a2,-24(s0)
  vprintf(1, fmt, ap);
 9ae:	85aa                	mv	a1,a0
 9b0:	4505                	li	a0,1
 9b2:	00000097          	auipc	ra,0x0
 9b6:	dce080e7          	jalr	-562(ra) # 780 <vprintf>
}
 9ba:	60e2                	ld	ra,24(sp)
 9bc:	6442                	ld	s0,16(sp)
 9be:	6125                	addi	sp,sp,96
 9c0:	8082                	ret

00000000000009c2 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 9c2:	1141                	addi	sp,sp,-16
 9c4:	e422                	sd	s0,8(sp)
 9c6:	0800                	addi	s0,sp,16
  Header *bp, *p;

  bp = (Header*)ap - 1;
 9c8:	ff050693          	addi	a3,a0,-16
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 9cc:	00000797          	auipc	a5,0x0
 9d0:	24c7b783          	ld	a5,588(a5) # c18 <freep>
 9d4:	a02d                	j	9fe <free+0x3c>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 9d6:	4618                	lw	a4,8(a2)
 9d8:	9f2d                	addw	a4,a4,a1
 9da:	fee52c23          	sw	a4,-8(a0)
    bp->s.ptr = p->s.ptr->s.ptr;
 9de:	6398                	ld	a4,0(a5)
 9e0:	6310                	ld	a2,0(a4)
 9e2:	a83d                	j	a20 <free+0x5e>
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 9e4:	ff852703          	lw	a4,-8(a0)
 9e8:	9f31                	addw	a4,a4,a2
 9ea:	c798                	sw	a4,8(a5)
    p->s.ptr = bp->s.ptr;
 9ec:	ff053683          	ld	a3,-16(a0)
 9f0:	a091                	j	a34 <free+0x72>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 9f2:	6398                	ld	a4,0(a5)
 9f4:	00e7e463          	bltu	a5,a4,9fc <free+0x3a>
 9f8:	00e6ea63          	bltu	a3,a4,a0c <free+0x4a>
{
 9fc:	87ba                	mv	a5,a4
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 9fe:	fed7fae3          	bgeu	a5,a3,9f2 <free+0x30>
 a02:	6398                	ld	a4,0(a5)
 a04:	00e6e463          	bltu	a3,a4,a0c <free+0x4a>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 a08:	fee7eae3          	bltu	a5,a4,9fc <free+0x3a>
  if(bp + bp->s.size == p->s.ptr){
 a0c:	ff852583          	lw	a1,-8(a0)
 a10:	6390                	ld	a2,0(a5)
 a12:	02059813          	slli	a6,a1,0x20
 a16:	01c85713          	srli	a4,a6,0x1c
 a1a:	9736                	add	a4,a4,a3
 a1c:	fae60de3          	beq	a2,a4,9d6 <free+0x14>
    bp->s.ptr = p->s.ptr->s.ptr;
 a20:	fec53823          	sd	a2,-16(a0)
  if(p + p->s.size == bp){
 a24:	4790                	lw	a2,8(a5)
 a26:	02061593          	slli	a1,a2,0x20
 a2a:	01c5d713          	srli	a4,a1,0x1c
 a2e:	973e                	add	a4,a4,a5
 a30:	fae68ae3          	beq	a3,a4,9e4 <free+0x22>
    p->s.ptr = bp->s.ptr;
 a34:	e394                	sd	a3,0(a5)
  } else
    p->s.ptr = bp;
  freep = p;
 a36:	00000717          	auipc	a4,0x0
 a3a:	1ef73123          	sd	a5,482(a4) # c18 <freep>
}
 a3e:	6422                	ld	s0,8(sp)
 a40:	0141                	addi	sp,sp,16
 a42:	8082                	ret

0000000000000a44 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 a44:	7139                	addi	sp,sp,-64
 a46:	fc06                	sd	ra,56(sp)
 a48:	f822                	sd	s0,48(sp)
 a4a:	f426                	sd	s1,40(sp)
 a4c:	f04a                	sd	s2,32(sp)
 a4e:	ec4e                	sd	s3,24(sp)
 a50:	e852                	sd	s4,16(sp)
 a52:	e456                	sd	s5,8(sp)
 a54:	e05a                	sd	s6,0(sp)
 a56:	0080                	addi	s0,sp,64
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 a58:	02051493          	slli	s1,a0,0x20
 a5c:	9081                	srli	s1,s1,0x20
 a5e:	04bd                	addi	s1,s1,15
 a60:	8091                	srli	s1,s1,0x4
 a62:	0014899b          	addiw	s3,s1,1
 a66:	0485                	addi	s1,s1,1
  if((prevp = freep) == 0){
 a68:	00000517          	auipc	a0,0x0
 a6c:	1b053503          	ld	a0,432(a0) # c18 <freep>
 a70:	c515                	beqz	a0,a9c <malloc+0x58>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 a72:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 a74:	4798                	lw	a4,8(a5)
 a76:	02977f63          	bgeu	a4,s1,ab4 <malloc+0x70>
 a7a:	8a4e                	mv	s4,s3
 a7c:	0009871b          	sext.w	a4,s3
 a80:	6685                	lui	a3,0x1
 a82:	00d77363          	bgeu	a4,a3,a88 <malloc+0x44>
 a86:	6a05                	lui	s4,0x1
 a88:	000a0b1b          	sext.w	s6,s4
  p = sbrk(nu * sizeof(Header));
 a8c:	004a1a1b          	slliw	s4,s4,0x4
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*)(p + 1);
    }
    if(p == freep)
 a90:	00000917          	auipc	s2,0x0
 a94:	18890913          	addi	s2,s2,392 # c18 <freep>
  if(p == (char*)-1)
 a98:	5afd                	li	s5,-1
 a9a:	a895                	j	b0e <malloc+0xca>
    base.s.ptr = freep = prevp = &base;
 a9c:	00000797          	auipc	a5,0x0
 aa0:	19478793          	addi	a5,a5,404 # c30 <base>
 aa4:	00000717          	auipc	a4,0x0
 aa8:	16f73a23          	sd	a5,372(a4) # c18 <freep>
 aac:	e39c                	sd	a5,0(a5)
    base.s.size = 0;
 aae:	0007a423          	sw	zero,8(a5)
    if(p->s.size >= nunits){
 ab2:	b7e1                	j	a7a <malloc+0x36>
      if(p->s.size == nunits)
 ab4:	02e48c63          	beq	s1,a4,aec <malloc+0xa8>
        p->s.size -= nunits;
 ab8:	4137073b          	subw	a4,a4,s3
 abc:	c798                	sw	a4,8(a5)
        p += p->s.size;
 abe:	02071693          	slli	a3,a4,0x20
 ac2:	01c6d713          	srli	a4,a3,0x1c
 ac6:	97ba                	add	a5,a5,a4
        p->s.size = nunits;
 ac8:	0137a423          	sw	s3,8(a5)
      freep = prevp;
 acc:	00000717          	auipc	a4,0x0
 ad0:	14a73623          	sd	a0,332(a4) # c18 <freep>
      return (void*)(p + 1);
 ad4:	01078513          	addi	a0,a5,16
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 ad8:	70e2                	ld	ra,56(sp)
 ada:	7442                	ld	s0,48(sp)
 adc:	74a2                	ld	s1,40(sp)
 ade:	7902                	ld	s2,32(sp)
 ae0:	69e2                	ld	s3,24(sp)
 ae2:	6a42                	ld	s4,16(sp)
 ae4:	6aa2                	ld	s5,8(sp)
 ae6:	6b02                	ld	s6,0(sp)
 ae8:	6121                	addi	sp,sp,64
 aea:	8082                	ret
        prevp->s.ptr = p->s.ptr;
 aec:	6398                	ld	a4,0(a5)
 aee:	e118                	sd	a4,0(a0)
 af0:	bff1                	j	acc <malloc+0x88>
  hp->s.size = nu;
 af2:	01652423          	sw	s6,8(a0)
  free((void*)(hp + 1));
 af6:	0541                	addi	a0,a0,16
 af8:	00000097          	auipc	ra,0x0
 afc:	eca080e7          	jalr	-310(ra) # 9c2 <free>
  return freep;
 b00:	00093503          	ld	a0,0(s2)
      if((p = morecore(nunits)) == 0)
 b04:	d971                	beqz	a0,ad8 <malloc+0x94>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 b06:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 b08:	4798                	lw	a4,8(a5)
 b0a:	fa9775e3          	bgeu	a4,s1,ab4 <malloc+0x70>
    if(p == freep)
 b0e:	00093703          	ld	a4,0(s2)
 b12:	853e                	mv	a0,a5
 b14:	fef719e3          	bne	a4,a5,b06 <malloc+0xc2>
  p = sbrk(nu * sizeof(Header));
 b18:	8552                	mv	a0,s4
 b1a:	00000097          	auipc	ra,0x0
 b1e:	b70080e7          	jalr	-1168(ra) # 68a <sbrk>
  if(p == (char*)-1)
 b22:	fd5518e3          	bne	a0,s5,af2 <malloc+0xae>
        return 0;
 b26:	4501                	li	a0,0
 b28:	bf45                	j	ad8 <malloc+0x94>
